package com.shen.modules.sys.controller;

import com.shen.common.utils.PageUtils;
import com.shen.common.utils.R;
import com.shen.modules.sys.entity.SysMonitorEntity;
import com.shen.modules.sys.service.SysMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 监控controller
 * @author sjl
 */
@RestController
@RequestMapping("/sys")
public class SysMonitorController extends AbstractController  {
    @Autowired
    private SysMonitorService sysMonitorService;

    @RequestMapping(value = "/reportMonitor", method = RequestMethod.POST)
    public R reportMonitor(@RequestBody SysMonitorEntity sysMonitor) {
        if (sysMonitor.getErrorInfo() != null) {
            sysMonitorService.reportMonitorService(sysMonitor);
        }
        return R.ok();
    }

    @RequestMapping(value = "/selMonitor")
    public R selMonitor(@RequestParam Map<String, Object> params) {
        PageUtils page = sysMonitorService.queryPage(params);

        return R.ok().put("page", page);
    }

    @RequestMapping(value = "/monitorDel")
    public R monitorDel(@RequestBody Long[] monitorIds) {
        sysMonitorService.deleteBatchIds(Arrays.asList(monitorIds));
        return R.ok();
    }
}
